﻿<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="css/bootstrap.css" rel="stylesheet" />
    <style>
        .loader {
            display: none;
        }

        .main {
            margin-top: 65px;
        }

        html, body {
            background: #eee;
        }
        .main-2 {
            padding: 10px;
        }
        .table-head {
            font-weight: bold;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">LOOK</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse" aria-expanded="false" style="height: 1px;">
                <ul class="nav navbar-nav">
                    <li class="active">
                        <a href="profile.html">Профиль</a>
                    </li>
                    <li>
                        <a href="graphic.html">График работы</a>
                    </li>
                    <li>
                        <a href="usersList.html">Список сотрудников</a>
                    </li>
                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </nav>

    <div class="container main">
        <div class="jumborton">
            <div class="panel panel-primary">
                <div class="panel-body">
                    <div class="row main-2">
                        <div>Профиль пользователя</div>
                        <table class="table table-hover">
                            <tr>
                                <td class="table-head">Фамилия:</td>
                                <td id="lastName"></td>
                                <td>
                                    <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                                </td>
                            </tr>
                            <tr>
                                <td class="table-head">Имя:</td>
                                <td id="name"></td>
                                <td>
                                    <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                                </td>
                            </tr>
                            <tr>
                                <td class="table-head">Отчество:</td>
                                <td id="middleName"></td>
                                <td>
                                    <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                                </td>
                            </tr>
                            <tr>
                                <td class="table-head">Дата рожд.:</td>
                                <td id="birthDate"></td>
                                <td>
                                    <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                                </td>
                            </tr>
                            <tr>
                                <td class="table-head">Дата нач. работы.:</td>
                                <td id="startWorkDate"></td>
                                <td>
                                    <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                                </td>
                            </tr>
                            <tr>
                                <td class="table-head">Ст. часа работы:</td>
                                <td id="salary"></td>
                                <td>
                                    <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>




    <!--<div class="container main">
        <div class="jumborton">
            <div class="panel panel-primary">
                <div class="panel-body">
                    <div class="row">
                        <div class="col-xs-12  login-box">
                            <div class="input-group">
                                <span class="input-group-addon">Фамилия</span>
                                <label class="form-control" id="lastName"></label>
                                <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                            </div>
                            <div class="input-group">
                                <span class="input-group-addon">Имя</span>
                                <label class="form-control" id="name"></label>
                                <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                            </div>
                            <div class="input-group">
                                <span class="input-group-addon">Отчество</span>
                                <label class="form-control" id="middleName"></label>
                                <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                            </div>
                            <div class="input-group">
                                <span class="input-group-addon">Дата рожд.</span>
                                <label class="form-control" id="birthDate"></label>
                                <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                            </div>
                            <div class="input-group">
                                <span class="input-group-addon">Дата нач. работы</span>
                                <label class="form-control" id="startWorkDate"></label>
                                <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                            </div>
                            <div class="input-group">
                                <span class="input-group-addon">Ст. часа</span>
                                <label class="form-control" id="salary"></label>
                                <img src="Content/images/ajax-loader.gif" class="loader" width="30" height="30" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>-->
    <script src="scripts/jquery-1.9.1.js"></script>
    <script src="scripts/bootstrap.min.js"></script>
    <script>
        $(document).ready(function () {
            var baseUrl = localStorage.getItem("baseUrl");
            var userLogin = localStorage.getItem("userLogin");
            if (!userLogin) {
                window.location = "index.html";
            }

            $.ajax({
                url: baseUrl + "/api/accountapi",
                type: "GET",
                data: { userLogin: userLogin },
                error: function () {
                    $(".loader").hide();
                    alert("Произошла ошибка, пожалуйста, попробуйте зайти позже");
                },
                beforeSend: function () {
                    $(".loader").show();
                },
                success: function (response) {
                    $(".loader").hide();
                    if (!response) {
                        alert("Не удалось получить данные с сервера");
                    } else {
                        localStorage.setItem("userId", response.id);
                        $("#name").text(response.name);
                        $("#lastName").text(response.lastName);
                        $("#middleName").text(response.middleName);
                        $("#birthDate").text(response.dateBirth);
                        $("#startWorkDate").text(response.startWorkDate);
                        $("#salary").text(response.salary);
                    }
                }
            })
        });
    </script>
</body>
</html>